{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "Repair"

// By ArtemQa146

//  

if
    is_game_first_start
then
    0F00: load_special_model_dff "modelsqa\RSpanner" txd "modelsqa\RuralRepair" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\Rural car repairs.ini" section "Models" key "Spanner"
    0F00: load_special_model_dff "modelsqa\Drill" txd "modelsqa\RuralRepair" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\Rural car repairs.ini" section "Models" key "Drill"
    0F00: load_special_model_dff "modelsqa\Sponge" txd "modelsqa\RuralRepair" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\Rural car repairs.ini" section "Models" key "Sponge"
    0F00: load_special_model_dff "modelsqa\GasPetrol" txd "modelsqa\RuralRepair" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\Rural car repairs.ini" section "Models" key "GasPetrol"
end

//  
0AF0: 29@ = read_int_from_ini_file "cleo\Rural car repairs.ini" section "Settings" key "Icon ID"
0AF0: 28@ = read_int_from_ini_file "cleo\Rural car repairs.ini" section "Settings" key "Icon on radar"
0AF0: 27@ = read_int_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fourth Enable"
0AF0: 26@ = read_int_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fifth Enable"
0AF0: 25@ = read_int_from_ini_file "cleo\Rural car repairs.ini" section "Settings" key "Enable in mission"

//  
0AF2: 1@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "first x"
0AF2: 2@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "first y"
0AF2: 3@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "first z"
0AF2: 4@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "first angle"

0AF2: 5@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "second x"
0AF2: 6@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "second y"
0AF2: 7@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "second z"
0AF2: 8@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "second angle"

0AF2: 9@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "third x"
0AF2: 10@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "third y"
0AF2: 11@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "third z"
0AF2: 12@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "third angle"

//  
if
    27@ == 1
then
    0AF2: 13@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fourth x"
    0AF2: 14@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fourth y"
    0AF2: 15@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fourth z"
    0AF2: 16@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fourth angle"
    if
        28@ == 1
    then
        0E2A: add_cleo_blip 29@ position 13@ 14@ is_short 1 RGBA 255 255 255 255 store_to 0@
    end
end

if
    26@ == 1
then
    0AF2: 17@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fifth x"
    0AF2: 18@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fifth y"
    0AF2: 19@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fifth z"
    0AF2: 20@ = read_float_from_ini_file "cleo\Rural car repairs.ini" section "coords" key "fifth angle"
    if
        28@ == 1
    then
        0E2A: add_cleo_blip 29@ position 17@ 18@ is_short 1 RGBA 255 255 255 255 store_to 0@
    end
end

//   
if
    28@ == 1
then
    0E2A: add_cleo_blip 29@ position 1@ 2@ is_short 1 RGBA 255 255 255 255 store_to 0@
    0E2A: add_cleo_blip 29@ position 5@ 6@ is_short 1 RGBA 255 255 255 255 store_to 0@
    0E2A: add_cleo_blip 29@ position 9@ 10@ is_short 1 RGBA 255 255 255 255 store_to 0@
end

//    by vladvo
0A8C: write_memory 0x6D2C68 size 1 value 0x04 virtual_protect 0
0A8C: write_memory 0x6D2C69 size 1 value 0xC3 virtual_protect 0
0A8C: write_memory 0x6D2C6A size 1 value 0x86 virtual_protect 0
//-------------------------------------------------------------


while true
wait 0
if
    Player.Defined(0)
then
    gosub @Mission
    if
        24@ == true
    then
    // 1
    if
        0EEA: locate_char_distance_to_coordinates $player_actor pos 1@ 2@ 3@ radius 30.0
    then
            if
                0103:   actor $PLAYER_ACTOR in_sphere 1@ 2@ 3@ radius 3.0 3.0 3.0 sphere 1 stopped_in_car
            then
                0@ = true
                0A92: stream_custom_script "Rural car repairs.qa" 0@ 4@
                repeat
                wait 1000
                    0AAA: 31@ = get_script_struct_named "Rrepair"
                        if and
                            not locate_char_distance_to_coordinates $player_actor pos 1@ 2@ 3@ radius 10.0
                            not 31@ > 0 // ,   
                        then
                            break
                        end
                until not player.Defined(0)
            end
        end
        
    // 2
    if
        0EEA: locate_char_distance_to_coordinates $player_actor pos 5@ 6@ 7@ radius 30.0
    then
            if
                0103:   actor $PLAYER_ACTOR in_sphere 5@ 6@ 7@ radius 3.0 3.0 3.0 sphere 1 stopped_in_car
            then
                0@ = true
                0A92: stream_custom_script "Rural car repairs.qa" 0@ 8@
                repeat
                wait 1000
                    0AAA: 31@ = get_script_struct_named "Rrepair"
                        if and
                            not locate_char_distance_to_coordinates $player_actor pos 5@ 6@ 7@ radius 10.0
                            not 31@ > 0 // ,   
                        then
                            break
                        end
                until not player.Defined(0)
            end
        end
        
    // 3
    if
        0EEA: locate_char_distance_to_coordinates $player_actor pos 9@ 10@ 11@ radius 30.0
    then
            if
                0103:   actor $PLAYER_ACTOR in_sphere 9@ 10@ 11@ radius 3.0 3.0 3.0 sphere 1 stopped_in_car
            then
                0@ = true
                0A92: stream_custom_script "Rural car repairs.qa" 0@ 12@
                repeat
                wait 1000
                    0AAA: 31@ = get_script_struct_named "Rrepair"
                        if and
                            not locate_char_distance_to_coordinates $player_actor pos 9@ 10@ 11@ radius 10.0
                            not 31@ > 0 // ,   
                        then
                            break
                        end
                until not player.Defined(0)
            end
        end
        
// 4
if
    27@ == 1
then
    if
        0EEA: locate_char_distance_to_coordinates $player_actor pos 13@ 14@ 15@ radius 30.0
    then
            if
                0103:   actor $PLAYER_ACTOR in_sphere 13@ 14@ 15@ radius 3.0 3.0 3.0 sphere 1 stopped_in_car
            then
                0@ = true
                0A92: stream_custom_script "Rural car repairs.qa" 0@ 16@
                repeat
                wait 1000
                    0AAA: 31@ = get_script_struct_named "Rrepair"
                        if and
                            not locate_char_distance_to_coordinates $player_actor pos 13@ 14@ 15@ radius 10.0
                            not 31@ > 0 // ,   
                        then
                            break
                        end
                until not player.Defined(0)
            end
        end
    end
        
// 5
if
    26@ == 1
then
    if
        0EEA: locate_char_distance_to_coordinates $player_actor pos 17@ 18@ 19@ radius 30.0
    then
            if
                0103:   actor $PLAYER_ACTOR in_sphere 17@ 18@ 19@ radius 3.0 3.0 3.0 sphere 1 stopped_in_car
            then
                0@ = true
                0A92: stream_custom_script "Rural car repairs.qa" 0@ 20@
                repeat
                wait 1000
                    0AAA: 31@ = get_script_struct_named "Rrepair"
                        if and
                            not locate_char_distance_to_coordinates $player_actor pos 17@ 18@ 19@ radius 10.0
                            not 31@ > 0 // ,   
                        then
                            break
                        end
                until not player.Defined(0)
            end
        end
    end
end
end
end

:Mission
if
    25@ == 1
then
    24@ = true
else
    if
        $ONMISSION == 0
    then
        24@ = true
    else
        24@ = false
    end
end
return

